﻿using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Win8CalendarDemo
{
    public class ViewModel : INotifyPropertyChanged
    {
        public ViewModel()
        {
            TestItems = new ObservableCollection<TestItem>(
                new TestItem[]
                    {
                        new TestItem { RandomTest = "Item1", CurrentDate = DateTime.Today.AddDays(1) },
                        new TestItem { RandomTest = "Item2", CurrentDate = DateTime.Today.AddDays(2) },
                        new TestItem { RandomTest = "Item3", CurrentDate = DateTime.Today.AddDays(3) }
                    }
                );
        }

        private ObservableCollection<TestItem> _testItems;

        public ObservableCollection<TestItem> TestItems
        {
            get { return _testItems; }
            set { _testItems = value; OnPropertyChanged();}
        }
        

        private string _randomText = string.Empty;

        public string RandomTest
        {
            get { return _randomText; }
            set { _randomText = value; OnPropertyChanged(); }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
